<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
      var worker = new Worker("./worker.js");
      console.log('=====')
      console.log('=====')

      worker.postMessage({
        val:'开始'
      })
      worker.onmessage = function(e){
        console.log(e)
        console.log(e.data.val)
      }
      // worker.terminate() 外部终止
      console.log('=====')
      console.log('=====')
  </script>
</body>
</html>